package com.firstclass.exception.handler;

import com.fasterxml.jackson.annotation.JsonFormat;

import java.time.LocalDateTime;

public class ApiError {
    private Integer status = 400;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime timeStamp;
    private String msg;

    private ApiError() {
        this.timeStamp = LocalDateTime.now();
    }

    public static ApiError error(String message) {
        final ApiError apiError = new ApiError();
        apiError.setMsg(message);
        return apiError;
    }

    public static ApiError error(Integer status, String message) {
        final ApiError apiError = new ApiError();
        apiError.setStatus(status);
        apiError.setMsg(message);
        return apiError;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public LocalDateTime getTimeStamp() {
        return timeStamp;
    }

    public void setTimeStamp(LocalDateTime timeStamp) {
        this.timeStamp = timeStamp;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
